Great work! This lesson covered namespaces. You learned that their primary purpose in XML is to ensure that identical tag names referring to different content don't cause confusion when merging XML documents. And you now know that their main purpose in VB or other programming languages is to organize related commands into sets of code libraries.
You also know how to add the final feature to the cookbook program: allowing the user to edit recipes and having the program automatically update the recipes.xml file with your changes. You saw how fixing bugs can be challenging (and even frustrating at times), but you also saw that bugs can offer a puzzle that's fun to solve!
Think you've got the hang of namespaces? Try out this quick game and see how you do!
In the next lesson, you'll create two new VB programs. I'll see you when you're ready!
Q: Can you use namespaces with attributes too?
A: It's not illegal to add a namespace prefix to attributes, but it's hardly ever necessary. That's because attributes are rarely ambiguous—they're contained within an element. Think of it this way: An attribute automatically inherits the namespace of its element, just as your house cat automatically shares your address.
Users almost always like feedback—and they typically want to know if something has changed. For today's assignment, I want you to add a color cue that tells the users the program has saved their editing after they've finished editing it.
You can do this by changing the txtInstructions textbox's BackColor. Its current BackColor is 255, 224, 192, a tan. How about changing the BackColor to white if the user starts modifying the text? Then change it back to tan after the program saves the changes.
Here are the code lines you'll want to put into the proper places in the program. Figure out in which events you should insert them.
Here's the line to turn the textbox white:
And the one to turn it back to tan:
- Hint: You'll have to put the code that turns the textbox white into a new event that doesn't yet exist in the program.
- Second hint: It doesn't matter where in the events you put them, just that you choose the right events. (If you need to refresh your memory, return to Chapter 4 to review how to view all the available events.)
![hidden image or multimedia element hidden image or multimedia element](Introduction%20to%20XML_files/pf_placeholder_a.png)
This was a tough assignment, so if you got it even half right, congratulations. And if you got it totally right, bravo!